Flexible RCMES Workflow

  • Typical Steps:
    • Load Datasets
    • Temporal Regrids
    • Spatial Regrids
    • Evaluate Metrics
    • Plot Results

Make sure that OCW functions are available.


In [1]:
%matplotlib inline
from functions import loadDatasets, temporalRebins, commonLatLonGrid, spatialRegrids
from functions import computeMetrics, contourPlot, mymap

# def mymap(f, s): return map(f, s)           # sequential single-core map function


---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-0a14eee734d6> in <module>()
      1 get_ipython().magic('matplotlib inline')
----> 2 from functions import loadDatasets, temporalRebins, commonLatLonGrid, spatialRegrids
      3 from functions import computeMetrics, contourPlot, mymap
      4 
      5 # def mymap(f, s): return map(f, s)           # sequential single-core map function

ModuleNotFoundError: No module named 'functions'

Load Reference Dataset and one or more Model Datasets


In [2]:
path1 = "/Users/bdwilson/Documents/code/RCMES/Workshop/AFRICA_UC-WRF311_CTL_ERAINT_MM_50km-rg_1989-2008_tasmax.nc"
variable1 = "tasmax"
path2 = "/Users/bdwilson/Documents/code/RCMES/Workshop/AFRICA_KNMI-RACMO2.2b_CTL_ERAINT_MM_50km_1989-2008_tasmax.nc"
variable2 = "tasmax"

datasets = loadDatasets([(path1, variable1), (path2, variable2)], dir='./')
print datasets


  File "<ipython-input-2-06a67660f049>", line 7
    print datasets
                 ^
SyntaxError: Missing parentheses in call to 'print'

Temporal Rebin


In [ ]:
import ocw.dataset_processor as dsp
from datetime import timedelta

timeRes=timedelta(days=365)
datasets = temporalRebins(datasets, timeRes)

Spatial Regrid


In [ ]:
latRes = 1.0     # degrees
lonRes = 1.0     # degrees
lats, lons = commonLatLonGrid(datasets, latRes, lonRes)
# Find common spatial bounds, return desired grid with specified resolution

datasets = spatialRegrids(datasets, lats, lons)

Compute Metric(s)


In [ ]:
metricNames = ['Bias']
results = computeMetrics(datasets, metricNames, subregions=None)
bias = results[0][0]

Plot Bias between two models as time-series of contour maps


In [ ]:
outputName = "wrf_bias_compared_to_knm"
config = {'gridshape': (4, 5),
          'ptitle': 'TASMAX Bias of WRF Compared to KNMI (1989 - 2008)',
          'subtitles': range(1989, 2009, 1)
          }

plotFile = contourPlot(bias, lats, lons, outputName, **config)

Display Plot


In [ ]:
from IPython.display import Image, display

display(Image(plotFile))

In [ ]: